#!/bin/bash
#
# Copyright (c) 2017 Kris Occhipint.
# http://filmsbykris.com
# License: https://www.gnu.org/licenses/gpl-3.0.txt
# RadioPower
# This program is free software: you can redistribute it and/or modify  
# it under the terms of the GNU General Public License as published by  
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#       :GPLv3
#====================================================================

grep -e '$GPRMC' "$1"|grep '^15'|while read line;
do
  ts="$(echo "$line"|cut -d\- -f1)"
  echo -n "$ts,"
  grep "$ts" "$1"|grep -e '$GPRMC'|grep ',N,'|\
    grep ',W,'|\
    cut -d\, -f4,5,6,7|\
    grep ',08'|
    while read l;
    do
      echo -n "${l}',"
        #sed "s/,0/0',-/g";
      grep "$ts" "$1"|grep -e 'POWER'|cut -d\, -f3,4,7,8
    done
  done|grep '^15'|grep -v -e 'nan' -e 'A,'